SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO


/** Create Stored Procedures **/

CREATE PROCEDURE [dbo].[DnnProduct_PWSyncDashBoard_RefreshAllSyncStats]
	@ExcludeList NVARCHAR(1000)
AS
BEGIN
	DECLARE @sql NVARCHAR(MAX)
	
	BEGIN TRANSACTION

	BEGIN TRY
		
		IF (LEN(@ExcludeList) > 0) 
		BEGIN
			SET @sql = 'DELETE FROM DnnProduct_PWSyncDashBoard_LastSyncStatuses WHERE [DBName] IN (' + @ExcludeList + ')'	
			EXECUTE sp_executesql @sql
		END
				
		EXEC dbo.[DnnProduct_PWSyncDashBoard_PW10SyncStatsCheck] @ExcludeList
		
		EXEC dbo.[DnnProduct_PWSyncDashBoard_PWCSyncStatsCheck] @ExcludeList
		
		SELECT 0
	END TRY
	BEGIN CATCH
		SELECT ERROR_MESSAGE() 
		IF @@TRANCOUNT > 0
			ROLLBACK TRANSACTION
	END CATCH

	IF @@TRANCOUNT > 0
		COMMIT TRANSACTION
END
GO
